import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

// var _import = file => require('@/views/' + file + '.vue').default;
var _import = file => {
  return () => System.import("@/views/" + file + ".vue");
};

import Layout from "../views/layout/Layout";

export const constantRouterMap = [
  {
    title: "商品",
    name:'goods',
    children: [{
        path: "/goods",
        name:'goods:manage',
        component: Layout,
        
        meta: {
          title: "商品管理",
          icon: "dashboard"
        },
        children: [
          {
            path: "index",
            name: "goods:goodslist",
            component: _import("goods/index"),
            meta: {
              title: "商品列表",
              icon: "dashboard"
            }
          },
          {
            path: "goods_sort",
            name: "goods_sort:manage",
            component: _import("goods/sort_settings"),
            meta: {
              title: "商品分类筛选",
              icon: "dashboard"
            }
          },
          {
            path: "special",
            name: "special:goods",
            component: _import("goods/special"),
            meta: {
              title: "商品特价",
              icon: "dashboard"
            },
            children:[
              {
                name:'goods.special_center.manage',
                component:_import('goods/special_manage'),
                path: "manage",
                hidden:true,
                meta: {
                  title: "特价商品详情",
                  icon: "dashboard",
                  
                  noCache: true
                }
              }
            ]
          },
          {
            path: "goodsoplog",
            name: "goods:goodsoplog",
            component: _import("goods/oplog"),
            meta: {
              title: "查询商品管理操作记录",
              icon: "dashboard"
            }
          }
        ]
      },
      {
        path: "/brand",
        component: Layout,
        name:'goods_brand:main',
        meta: {
          title: "商品品牌",
          icon: "dashboard"
        },
        children: [{
            path: "index",
            name: "goods_brand:manage",
            component: _import("goods_brand/index"),
            meta: {
              title: "商品品牌",
              icon: "dashboard"
            }
          },
          {
            path: "tag",
            name: "goods_tag:manage",
            component: _import("goods_tag/index"),
            meta: {
              title: "商品标签",
              icon: "dashboard"
            }
          },
          
          {
            path: "oplog",
            name: "goods_tag_brand:log",
            component: _import("goods_brand/log"),
            meta: {
              title: "查询品牌/标签操作记录",
              icon: "dashboard"
            }
          }
        ]
      },

      {
        path: "/goodsSettings",
        name:'goods_settings:main',
        component: Layout,
        meta: {
          title: "商品配置",
          icon: "dashboard"
        },
        children: [{
            path: "category",
            name: 'goods:goods_category',
            component: _import("goods_category/index"),
            meta: {
              title: "商品分类",
              icon: "dashboard"
            }
          },
          {
            path: "goods_type",
            name: 'goods:goods_type',
            component: _import("goods_type/index"),
            meta: {
              title: "商品类型",
              icon: "dashboard"
            }
          },
          {
            path: "oplog",
            name: 'goods:manageoplog',
            component: _import("goods_category/goodssettinglog"),
            meta: {
              title: "查询商品配置操作记录",
              icon: "dashboard"
            }
          }
        ]
      }
    ]
  }
  ,
  {
    title: "订单",
    name:'order',
    children: [{
        path: "/order",
        name:'order:manage',
        component: Layout,
        meta: {
          title: "订单管理",
          icon: "dashboard"
        },
        children: [{
            path: "index",
            name: 'order:list',
            component: _import("order_record/index"),
            meta: {
              title: "订单列表",
              icon: "dashboard"
            }
          },
          {
            path: "settings",
            name: 'order:settings',
            component: _import("order_record/settings"),
            meta: {
              title: "订单设置",
              icon: "dashboard"
            }
          },
          {
            path: "goods_comments",
            name: 'order:comment',
            component: _import("goods_comments/index"),
            meta: {
              title: "订单评论",
              icon: "dashboard"
            }
          }
        ]
      },
      {
        path: "/return",
        component: Layout,
        name:'order_refund:main',
        meta: {
          title: "退货（款）",
          icon: "dashboard"
        },
        children: [{
            path: "refund",
            name: 'order:refund_money',
            component: _import("refund/index"),
            meta: {
              title: "退款(退货)申请单",
              icon: "dashboard"
            }
          } 
        ]
      }
       
    ]
  },
  {
    title: "会员",
    name:'user',
    children: [{
        path: "/user",
        component: Layout,
        name:'user:manage',
        meta: {
          title: "会员管理",
          icon: "dashboard"
        },
        children: [{
            path: "index",
            name: "user:list",
            component: _import("user/index"),
            meta: {
              title: "会员列表",
              icon: "dashboard"
            }
          } 
        ]
      }
      ,
       
      {
        path: "/feedback",
        name:'user:feedback',
        component: Layout,
        meta: {
          title: "客户反馈",
          icon: "dashboard"
        },
        children: [{
            path: "goods_consult",
            name: "goods:consult",
            component: _import("feedback/index"),
            meta: {
              title: "用户反馈",
              icon: "dashboard"
            }
          },
          {
            path: "goods_comments",
            name: "goods:comment",
            component: _import("goods_comments/index"),
            meta: {
              title: "商品评论",
              icon: "dashboard"
            }
          }
          
        ]
      }
    ]
  },
 
  
  {
    title: "财务",
    name:'finance',
    children: [{
      path: "/finance",
      component: Layout,
      name:'finance:list',
      meta: {
        title: "财务报表",
        icon: "dashboard"
      },
      children: [
        {
          path: "settled_sum",
          name: "finance:settled_sum",
          component: _import("finance/settled_sum"),
          meta: {
            title: "已结算汇总表",
            icon: "dashboard"
          }
        },
        {
          path: "settled_detail",
          name: "finance:settled_detail",
          component: _import("finance/settled_detail"),
          meta: {
            title: "已结算明细表",
            icon: "dashboard"
          }
        },
        {
          path: "notsettled_sum",
          name: "finance:notsettled_sum",
          component: _import("finance/notsettled_sum"),
          meta: {
            title: "未结算汇总表",
            icon: "dashboard"
          }
        },
        {
          path: "notsettled_detail",
          name: "finance:notsettled_detail",
          component: _import("finance/notsettled_detail"),
          meta: {
            title: "未结算明细表",
            icon: "dashboard"
          }
        }
      ]
    }]
  },
   
  {
    title: "系统",
    name:'system',
    children: [{
      path: "/system",
      component: Layout,
      name:'sytem:safe',
      meta: {
        title: "权限安全",
        icon: "dashboard"
      },
      children: [{
          path: "admin",
          name: "system:admin",
          component: _import("admin/index"),
          meta: {
            title: "账户管理",
            icon: "dashboard"
          }
        },
        {
          path: "role",
          name: "system:role",
          component: _import("role/index"),
          meta: {
            title: "角色管理",
            icon: "dashboard"
          }
        }
        
      ]
    }]
  },
  {
    title: "油站",
    name:'gas_station',
    children: [{
      path: "/gas_station",
      component: Layout,
      name:'gas_station:home',
      meta: {
        title: "油站管理",
        icon: "dashboard"
      },
      children: [{
          path: "manage",
          name: "gas_station:manage",
          component: _import("gas_station/index"),
          meta: {
            title: "油站管理",
            icon: "dashboard"
          }
        }
      ]
    }]
  },
  {
    title: "运营",
    name:'manage',
    children: [{
      path: "/system",
      component: Layout,
      name:'manage:manage',
      meta: {
        title: "运营管理",
        icon: "dashboard"
      },
      children: [
        {
        path: "ad",
        name: "manage:ad",
        component: _import("ad/index"),
        meta: {
          title: "广告管理",
          icon: "dashboard"
        }
      },
      
      {
        path: "message",
        name: "manage:message",
        component: _import("message/index"),
        meta: {
          title: "消息管理",
          icon: "dashboard"
        }
      }
    ]
    },
    {
      path: "/consult",
      component: Layout,
      name:'consult:manage',
      meta: {
        title: "咨询管理",
        icon: "dashboard"
      },
      children: [{
        path: "question",
        name: "question:manage",
        component: _import("question/index"),
        meta: {
          title: "常见问题",
          icon: "dashboard"
        }
      },
      {
        path: "commonpage",
        name: "commonpage:manage",
        component: _import("common_page/index"),
        meta: {
          title: "页面管理",
          icon: "dashboard"
        }
      },
      {
        path: "feedback",
        name: "feedback:manage",
        component: _import("feedback/index"),
        meta: {
          title: "留言反馈",
          icon: "dashboard"
        }
      }]
    }]
  },
  {
    title: "供应商管理",
    name:'provider:main',
    children: [{
      path: "/provider",
      name:'provider:manage',
      component: Layout,
      meta: {
        title: "供应商管理",
        icon: "dashboard"
      },
      children: [{
        path: "index",
        name: "provider:list",
        component: _import("provider/index"),
        meta: {
          title: "供应商列表",
          icon: "dashboard"
        }
      }]
    }]
  }
];

let _routers = [
 
  {
    path: "/login",
    name: "provider:login",
    component: _import("login/index"),
    hidden: true
  },

  {
    path: "/scan",
    name: "scan",
    component: _import("login/scan"),
    hidden: true
  },
  
  {
    path: "",
    redirect: "dashboard",
    hidden: true,
    component: Layout,
    children: [{
      path: "dashboard",
      component: _import("dashboard/index"),
      name: "dashboard",
      meta: {
        title: "首页",
        icon: "dashboard",
        noCache: true
      }
    }]
  }
];
constantRouterMap.forEach(router => {
  if (router.children) {
    _routers.push(...router.children)
  }
});

export default new Router({
  routes: _routers
});
